package com.yao.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yao.sys.entity.dto.UserDto;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 用户表
 *
 * @author autoCode
 * @version 1.0.0-SNAPSHOT
 * @date 2020-04-09
 */
@Mapper
@Repository
public interface UserMapper extends BaseMapper<UserDto> {

    @Select("select id, userName as username, password from sys_user where userName = #{username}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "roles", column = "id", javaType = List.class, many = @Many(
            select = "com.yao.sys.mapper.UserRoleRelMapper.findByUserId"))
    })
    com.yao.auth.entity.dto.UserDto findByUsername(String username);

}